import { reqSearchInfo } from "@/api";

const state = {
    goodsListInfo: {},
};

const getters = {
    // 商品信息列表
    attrsList(state) {
        return state.goodsListInfo.attrsList || [];
    },
    goodsList(state) {
        return state.goodsListInfo.goodsList || [];
    },
    trademarkList(state) {
        return state.goodsListInfo.trademarkList || [];
    },
};

const actions = {
    getGoodsListInfo({ commit }, params) {
        reqSearchInfo(params).then(res => {
            commit("RECEIVE_GOODSLISTINFO", { goodsListInfo: res });
        });
    },
};

const mutations = {
    RECEIVE_GOODSLISTINFO(state, { goodsListInfo }) {
        state.goodsListInfo = goodsListInfo;
    },
};

export default {
    namespaced: true,
    state,
    getters,
    actions,
    mutations,
};
